package com.tool.btn;

import com.tool.role.RoleData;
import com.tool.tcpimg.UIUtils;
import come.tool.JDialog.TiShiUtil;
import org.apache.commons.lang.StringUtils;
import org.come.Frame.OptionsJframe;
import org.come.Frame.ZhuFrame;
import org.come.Jpanel.ChooseLiangHaoTypeJpanel;
import org.come.Jpanel.MyLiangHaoJpanel;
import org.come.bean.LoginResult;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.until.FormsManagement;
import org.come.until.GsonUtil;
import org.wing.panel.LHMainFrame;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;

public class LiangHaoBtn extends MoBanBtn {
    //0上 1下 2顶 3底
    int typeBtn;
    private MyLiangHaoJpanel jpanel;
    private int p;

    public LiangHaoBtn(String iconpath, int type, Color[] colors,
                       Font font, String text, Integer typeBtn, MyLiangHaoJpanel jpanel) {
        // TODO Auto-generated constructor stub
        super(iconpath, type, colors);
        this.setText(text);
        this.typeBtn = typeBtn;
        this.setFont(UIUtils.TEXT_HY16);
        setVerticalTextPosition(SwingConstants.CENTER);
        setHorizontalTextPosition(SwingConstants.CENTER);
        this.p=p;
        this.jpanel = jpanel;
    }


    @Override
    public void chooseyes() {

    }

    @Override
    public void chooseno() {

    }

    @Override
    public void nochoose(MouseEvent e) {
        //获取当前选中的位置
        if(this.typeBtn == 1){       //开通靓号
            FormsManagement.showForm(641);
            String mes2 = Agreement.getAgreement().selllianghaoAgreement("SELLLIST");
            SendMessageUntil.toServer(mes2);
        }else if(this.typeBtn == 2){  //靓号染色
            final LoginResult login = RoleData.getRoleData().getLoginResult();
            if (login.getLianghaoexpire() == null) {
                ZhuFrame.getZhuJpanel().addPrompt2("请先购买靓号！#32");
                return;
            }
            FormsManagement.showForm(705);
        }else if(this.typeBtn == 3){  //频道显示

        }else if(this.typeBtn == 4){    //续费
            FormsManagement.showForm(706);
        }else if(this.typeBtn == 5){    //捐赠
            final LoginResult login = RoleData.getRoleData().getLoginResult();
            OptionsJframe.getOptionsJframe().getOptionsJpanel().showBox(TiShiUtil.droplh, null, "#W您确定要将靓号:#G" +login.getLiangHao() + " #W捐赠吗?  #R捐赠后无法找回三思而后行");
        }else if(this.typeBtn == 6){    //炼化
            final LoginResult login = RoleData.getRoleData().getLoginResult();
            if (login.getLianghaoexpire() == null) {
                ZhuFrame.getZhuJpanel().addPrompt2("请先购买靓号！#32");
                return;
            }
            if(this.getText().equals("炼化属性")){
                int type = 6;
                String lianghaoValue = RoleData.getRoleData().getLoginResult().getLianghaoValue();
                if(StringUtils.isNotBlank(lianghaoValue) && lianghaoValue.contains("@")){
                    String[] split = lianghaoValue.split("@");
                    type = Integer.parseInt(split[0]);
                }else{
                    type = 6;
                }

                FormsManagement.showForm(866);
                LHMainFrame.LHMainFrame().getLhMainPanel().changLeftType(type);
                return;
            }
        }
    }
}
